var config = require('./config');
var mongoose = require('mongoose');
var moment = require('moment');
var util = require('./models/util.js');

//var setting = require('./models/setting');

//mongoose
mongoose.connect('mongodb://' + config.host + '/' + config.db);

require('./models/user.js');
require('./models/category.js');
require('./models/store.js');
require('./models/battle.js');
require('./models/paper.js');

var User = mongoose.model('User');
var Category = mongoose.model('Category');
var Store = mongoose.model('Store');
var Battle = mongoose.model('Battle');
var Paper = mongoose.model('Paper');

/*
Battle.find({
    status : {
        $in : ['F','I']
    }
}).sort({
    status : 'desc'
}).sort({
    createTime: 'desc'
}).exec(function (err, battles) {
    battles.forEach(function(b){
        console.log(b.status);
    });
});
*/
/*
var userId = '5494f91d5021fb3639701b28';
Battle.find({
    users : userId
}).exec(function(err, battles){
    console.log(battles);
});
*/


var a = [1, 2, 3];
//var b = a.indexOf(3);
//console.log(b);
//console.log(a);

a.forEach(function(t, idx){
    console.log(t + ' ' + idx);
})